<template>
	<div class="news_container">
		<!-- 新闻标题 -->
		<h4 class="news_title">{{ newsInfo.title }}</h4>
		<p class="news_title_sm">
			<span>发表时间：{{ newsInfo.add_time | dataFormat }}</span>
			<span>点击{{ newsInfo.click }}次</span>
		</p>
		<hr>
		<!-- 新闻内容 -->
		<div class="news_contnet" v-html="newsInfo.content"></div>
		<!-- 新闻评论 -->
		<my-comment :id="this.$route.params.id"></my-comment>
	</div>
</template>

<script>
	import comment from '../publicComponent/comment.vue';
	export default {
		data(){
			return{
				id: this.$route.params.id,
				newsInfo: {}
			}
		},
		methods: {
			getNewInfo(){
				this.$http.get('api/getnew/' + this.id).then(res=>{
					if (res.body.status == 0) {
						this.newsInfo = res.body.message[0];
					}
				})
			}
		},
		created(){
			this.getNewInfo();
		},
		components: {
			'my-comment': comment
		}
	}
</script>

<style>
	.news_container{
		padding: 0 5px;
	}
	.news_container .news_title{
		font-size: 16px;
		text-align: center;
		padding: 15px 0;
		color: red;
	}
	.news_container .news_title_sm{
		font-size: 13px;
		display: flex;
		justify-content: space-between;
	}
	.news_container .news_contnet img{
		width: 100%;
	}
</style>
